<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>故障单车处理</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <style>
        body {
            background-color: #f2f2f2;
            font-family: 'Arial', sans-serif;
        }

        .layui-container {
            width: 500px;
            margin: 0 auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            margin-top: 20px;
        }

        .layui-form-item {
            margin-bottom: 20px;
            width: 68%;
            margin-left: 76px;
        }

        .layui-form-label {
            height: 43px;
            line-height: 26px;
            width: 100px;
            text-align: right;
            font-weight: bold;
        }

        .layui-input-block {
            margin-left: 120px;
        }

        .layui-btn {
            margin-top: 10px;
        }
    </style>
</head>

<body>
<div class="layui-container">
    <form class="layui-form layui-form-pane" action="">
        <div style="text-align: center;margin-bottom: 15px;">
            <p1 style="font-size:28px;">故障单车处理</p1>
        </div>
        <table class="layui-table">
            <thead>
            <tr>
                <th style="text-align: center">序号ID</th>
                <th style="text-align: center">单车编号</th>
                <th style="text-align: center">单车位置</th>
                <th style="text-align: center">故障原因</th>
                <th style="text-align: center">是否处理</th>
                <th style="text-align: center">按钮</th>
            </tr>
            </thead>
            <tbody id="tableBody">
            </tbody>
        </table>
    </form>
</div>

<script src="../layui/layui.js"></script>
<script src="../js/public.js"></script>
<script>
    layui.use(['form', 'layer', 'table'], function () {
        var table = layui.table
            , form = layui.form, $ = layui.$;
        var geturl = url + user.repairRecode;
        var element = layui.element;
        var $ = layui.jquery;

        $.ajax({
            type: "POST",
            url: geturl,
            data: JSON,
            contentType: 'application/json',
            success: function (data) {
                var tableBody = $('#tableBody');
                console.log(data)
                data.data.forEach(function (item) {
                    var row = '<tr>' +
                        '<td>' + item.repairID + '</td>' +
                        '<td id="bicycleNumber">' + item.bicycleNumber + '</td>' +
                        '<td>' + item.location + '</td>' +
                        '<td>' + item.userReason + '</td>' +
                        '<td>' + item.revert + '</td>' +
                        '<td>' + '<button type="button" class="layui-btn layui-btn-sm" onclick="handleRepair(' + item.repairID + ')">处理</button>' + '</td>' +
                        '</tr>';
                    tableBody.append(row);
                    localStorage.setItem("repairID", item.repairID);
                });
            }
        });
    });
    function handleRepair(repairID) {
        var geturl = url + user.updateRepair;
        var element = layui.element;
        var $ = layui.jquery;
        $.ajax({
            type: "POST",
            url: geturl,
            data: JSON.stringify({repairID: repairID}),
            contentType: 'application/json',
            success: function () {
                alert("处理成功")
                location.reload();
            }
        })
    }
</script>
</body>

</html>
